***Dataprep for Comparison of Survey quality***

**Merge all 

use "C:\Users\Administrator\Desktop\MAPLE\DATA\MAPLE\wave1_short"

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS8 2016\ESS2016_short.dta", force
drop _merge

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EBspring2019_short.dta", force
drop _merge


save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\allsurveys_w1.dta", replace

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\allsurveys_w1.dta"

drop if surveyname == "MAPLE"

destring age_MA edu_MA gender_MA, replace

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave2_short.dta", force

drop _merge

order voted_eu_MA, after (votechoice_eu_MA)

drop female-weight

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\allsurveys_w2.dta", replace

**Merge all - new ESS

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave1_short"

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS 2018\ESS2018_short.dta", force
drop _merge

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EBspring2019_short.dta", force
drop _merge


save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\allsurveys_w1_new.dta", replace

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\allsurveys_w1_new.dta"

drop if surveyname == "MAPLE"

destring age_MA edu_MA gender_MA, replace

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave2_short.dta", force
drop _merge

order voted_eu_MA, after (votechoice_eu_MA)

drop female Q5 name

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\allsurveys_w2_new.dta", replace

***Make merged version with all rounds of Maple and EB

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave1_short.dta"

rename Q5 education_MA
label var education_MA "Education MAPLE"
rename female female_MA
rename agegroup1 agegroup1_MA
rename agegroup2 agegroup2_MA
rename agegroup3 agegroup3_MA
rename edugroup1 edugroup1_MA
rename edugroup2 edugroup2_MA
rename edugroup3 edugroup3_MA
replace surveyname = "MAPLE1" if surveyname == "MAPLE"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave1_short_new.dta"

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave2_short.dta"

rename agegroup1 agegroup1_MA
rename agegroup2 agegroup2_MA
rename agegroup3 agegroup3_MA
rename edugroup1 edugroup1_MA
rename edugroup2 edugroup2_MA
rename edugroup3 edugroup3_MA
replace surveyname = "MAPLE2" if surveyname == "MAPLE"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave2_short.dta", replace

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\EB2019b.dta"

replace surveyname = "EB2" if surveyname == "EB2019b"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\EB2019b.dta", replace

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EBspring2019_short.dta"

replace surveyname = "EB1" if surveyname == "EB2019"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\EB2019a.dta"

use "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS 2018\ESS2018_short.dta"

replace surveyname = "ESS" if surveyname == "ESS2018"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\ESS2018.dta"

*Merge

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\ESS2018.dta"

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave2_short.dta", force
drop _merge 

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave1_short_new.dta", force
drop _merge 

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\EB2019a.dta", force
drop _merge

merge 1:1 country surveyname id using "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\EB2019b.dta", force
drop _merge

order country surveyname id

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\new\allwaves_new.dta", replace

***Add EB 95

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EB 91\ZA7576_v1-0-0.dta"

keep if country == 2 | country == 4 | country == 11 | country == 12 | country == 13 | country == 14 | country == 8

generate w3a=w1
replace w3a=0 if (cntry_de == 1) 
replace w3a=w3a+w3

recode country (14=4)
  
label define country 2 "Belgium" 11 "Greece" 12 "Spain" 8 "Ireland" 13 "Portugal" 4 "Germany"
label variable w3a "WEIGHT RESULT FROM TARGET - CNTR_DE"

generate surveyname = "EB2019b"
label var surveyname "Surveyname"

drop if country == 2 & q1_1 == 0
drop if country == 11 & q1_4 == 0
drop if country == 4 & q1_3 == 0
drop if country == 12 & q1_5 == 0
drop if country == 8 & q1_7 == 0
drop if country == 13 & q1_11 == 0

gen country1 = "Belgium" if country == 2
replace country1 = "Greece" if country == 11
replace country1 = "Spain" if country == 12
replace country1 = "Ireland" if country == 8
replace country1 = "Portugal" if country == 13
replace country1 = "Germany" if country == 4

drop country
rename country1 country
label var country "Country"
order country

drop if d11 <=17

gen female_eb = 0
replace female_eb = 1 if d10 == 2
label var female_eb "Female EB"

gen agegroup1_eb = 0
replace agegroup1_eb =1 if d11r2 == 1 | d11r2 == 2
label var agegroup1_eb "18-34 EB"

gen agegroup2_eb = 0
replace agegroup2_eb =1 if d11r2 == 3 | d11r2 == 4
label var agegroup2_eb "35-54 EB"

gen agegroup3_eb = 0
replace agegroup3_eb =1 if d11r2 == 5 | d11r2 == 6
label var agegroup3_eb "55+ EB"

rename serialid id
label var id "Respondent ID"
tostring id, replace

rename qg1_orig voted_eu_EB
label var voted_eu_EB "Voted EU EB"

rename qg2 party_voted_eu_EB
label var party_voted_eu_EB "Party voted EU EB"

rename qg15 voted_nat_EB
label var voted_nat_EB "Voted National EB"

rename qg16 party_voted_nat_EB
label var party_voted_nat_EB "Party voted Nat EB"

rename qf1 eu_membership_EB
label var eu_membership_EB "EU membership good/bad EB"

rename qf2 eu_benefit_EB
label var eu_benefit_EB "EU membership benefit EB"

rename d1 leftright_EB
label var leftright_EB "Left-right placement EB"

rename qa6a_10 trust_eu_EB
label var trust_eu_EB "Trust EU EB"

rename qa6a_8 trust_gov_EB
label var trust_gov_EB "Trust Government EB"

rename qa17a swd_EB
label var swd_EB "SWD EB"

rename d11 age_EB
label var age_EB "Age EB"

rename d10 gender_EB
label var gender_EB "Gender EB"

rename d8 edu_EB
label var edu_EB "Education EB"

rename w3a  weight_EB
label var weight_EB "Weight result from target EB"

rename qa1a_2 econ_eval_EB
label var econ_eval_EB "Economic evaluations EB"

keep agegroup3_eb agegroup2_eb agegroup1_eb female_eb surveyname weight_EB age_EB gender_EB edu_EB leftright_EB ///
party_voted_nat_EB voted_nat_EB party_voted_eu_EB voted_eu_EB swd_EB eu_benefit_EB eu_membership_EB trust_eu_EB ///
trust_gov_EB econ_eval_EB id country

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\EB2019b.dta", replace


**EUROBAROMETER DATA

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EBspring2019_short.dta"
use "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EBspring2019.dta"

rename b country

keep if country == 1 | country == 4 | country == 5 | country == 8 | country == 13 | country == 20 | country == 21

#delimit

generate w3a=w1
replace w3a=0 if (vger == 1) 
replace w3a=w3a+w3

recode country (21=20)
  
label define country 1 "Belgium" 4 "Greece" 5 "Spain" 8 "Ireland" 13 "Portugal" 20 "Germany"
label variable w3a "WEIGHT RESULT FROM TARGET - CNTR_DE"
#delimit

generate surveyname = "EB2019"
label var surveyname "Surveyname"

drop if country == 1 & q1_1 == 0
drop if country == 4 & q1_4 == 0
drop if country == 20 & q1_3 == 0
drop if country == 5 & q1_5 == 0
drop if country == 8 & q1_7 == 0
drop if country == 13 & q1_11 == 0

gen country1 = "Belgium" if country ==1
replace country1 = "Greece" if country == 4
replace country1 = "Spain" if country == 5
replace country1 = "Ireland" if country == 8
replace country1 = "Portugal" if country == 13
replace country1 = "Germany" if country == 20

drop country
rename country1 country
label var country "Country"
order country

drop  if vd11 <=17

gen female_eb = 0
replace female_eb = 1 if d10 == 2
label var female_eb "Female EB"

gen agegroup1_eb = 0
replace agegroup1_eb =1 if d11r2 == 1 | d11r2 == 2
label var agegroup1_eb "18-34 EB"

gen agegroup2_eb = 0
replace agegroup2_eb =1 if d11r2 == 3 | d11r2 == 4
label var agegroup2_eb "35-54 EB"

gen agegroup3_eb = 0
replace agegroup3_eb =1 if d11r2 == 5 | d11r2 == 6
label var agegroup3_eb "55+ EB"

gen edugroup1_eb = 0
replace edugroup1_eb =1 if d8 == 1
label var edugroup1_eb "Less than secondary EB"

gen edugroup2_eb = 0
replace edugroup2_eb =1 if d8 == 2
label var edugroup2_eb "Secondary EB"

gen edugroup3_eb = 0
replace edugroup3_eb =1 if d8 == 3
label var edugroup3_eb "More than secondary EB"

rename vd id
label var id "Respondent ID"
tostring id, replace

rename qa3s ref_eu_EB
label var ref_eu_EB "EU referendum EB"

rename qa6 vote_intention_eu_EB
label var vote_intention_eu_EB "Vote intention EU EB"

rename qa11 eu_membership_EB
label var eu_membership_EB "EU membership good/bad EB"

rename qa12 eu_benefit_EB
label var eu_benefit_EB "EU membership benefit EB"

rename d1 leftright_EB
label var leftright_EB "Left-right placement EB"

rename d72_1 voice_eu_EB
label var voice_eu_EB "Voice counts EU EB"

rename d72_3 countryvoice_eu_EB
label var countryvoice_eu_EB "Countries voice counts EU EB"

rename d78 image_eu_EB
label var image_eu_EB "Image EU EB"

rename d73_2 direction_eu_EB
label var direction_eu_EB "Direction EU EB"

rename d73_1 direction_country_EB
label var direction_country_EB "Direction country EB"

rename vd11 age_EB
label var age_EB "Age EB"

rename d10 gender_EB
label var gender_EB "Gender EB"

rename d8 edu_EB
label var edu_EB "Education EB"

rename w3a w1ger_EB
rename w1ger_EB weight_EB
label var weight_EB "Weight result from target EB"

rename d71 polint_EB
label var polint_EB "Political interest EB"

rename c14 socpro_EB
label var socpro_EB "Socioprofessional category EB"

rename d25 location_EB
label var location_EB "Rural/Urban location EB"

keep country surveyname id ref_eu_EB vote_intention_eu_EB eu_membership_EB eu_benefit_EB leftright_EB ///
edu_EB gender_EB age_EB voice_eu_EB countryvoice_eu_EB polint_EB socpro_EB location_EB ///
direction_country_EB direction_eu_EB image_eu_EB ///
female_eb agegroup1_eb agegroup2_eb agegroup3_eb edugroup1_eb edugroup2_eb edugroup3_eb weight_EB

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Eurobarometer\EBspring2019_short.dta", replace

**ESS DATA

use "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS8 2016\ESS2016_short.dta"

rename cntry country
keep if country == "BE" |  country == "DE" |  country == "ES" |  country == "IE" |  country == "PT"

gen country1 = "Belgium" if country == "BE"
replace country1 = "Spain" if country == "ES"
replace country1 = "Ireland" if country == "IE"
replace country1 = "Portugal" if country == "PT"
replace country1 = "Germany" if country == "DE"

drop country
rename country1 country
label var country "Country"
order country

keep eisced agea gndr clsprty prtclcbe prtclede prtclees prtcldie prtclept stfgov ///
pspwght dweight name idno country trstep mbtru domicil ///
vote prtvtcbe prtvede2 prtvtdes prtvtbie prtvtcpt polintr ///
lrscale stfeco stfgov stfdem euftf rlgdgr ctzshipc brncntr vteurmmb mbtru hinctnta

generate surveyname = "ESS2016"
label var surveyname "Surveyname"

keep if ctzshipc == "66"
keep if age >= 18
drop ctzshipc brncntr

gen female_ess = 0
replace female_ess = 1 if gndr == 2
label var female_ess "Female ESS"

gen agegroup1_ess = 0
replace agegroup1_ess =1 if agea <= 34
label var agegroup1_ess "18-34 ESS"

gen agegroup2_ess = 0
replace agegroup2_ess =1 if agea >34 & agea <55
label var agegroup2_ess "35-54 ESS"

gen agegroup3_ess = 0
replace agegroup3_ess =1 if agea >=55
label var agegroup3_ess "55+ ESS"

gen edugroup1_ess = 0
replace edugroup1_ess =1 if eisced == 1 | eisced == 2
label var edugroup1_ess "Less than secondary ESS"

gen edugroup2_ess = 0
replace edugroup2_ess =1 if eisced == 3 | eisced == 4
label var edugroup2_ess "Secondary ESS"

gen edugroup3_ess = 0
replace edugroup3_ess =1 if eisced == 5 | eisced == 6 | eisced == 7
label var edugroup3_ess "More than secondary ESS"

rename dweight dweight_ess
label var dweight_ess "Design weight ESS"

rename pspwght pspweight_ess
label var pspweight_ess "Post stratification & design weight ESS"

rename idno id
label var id "Respondent ID"
tostring id, replace

rename agea age_ess
label var age_ess "Age ESS"

rename gndr gender_ess
label var gender_ess "Gender ESS"

rename eisced edu_ess
label var edu_ess "Education ESS"

rename trstep trust_ep_ess
label var trust_ep_ess "Trust European parliament ESS"

rename vote voted_nat_ess
label var voted_nat_ess "Voted last election National ESS"

rename prtvtcbe voterecall_be_ess
label var voterecall_be_ess "Vote recall National ESS Belgium"

rename prtvede2 voterecall_de_ess
label var voterecall_de_ess "Vote recall National ESS Germany"

rename prtvtdes voterecall_es_ess
label var voterecall_es_ess "Vote recall National ESS Spain"

rename prtvtbie voterecall_ie_ess
label var voterecall_ie_ess "Vote recall National ESS Ireland"

rename prtvtcpt voterecall_pt_ess
label var voterecall_pt_ess "Vote recall National ESS Portugal"

rename lrscale leftright_ess
label var leftright_ess "Left-right placement ESS"

rename stfeco sat_eco_ess
label var sat_eco_ess "Satisfaction economy ESS"

rename stfgov sat_gov_ess
label var sat_gov_ess "Satisfaction government ESS"

rename stfdem swd_ess
label var swd_ess "SWD ESS"

rename euftf eu_integr_ess
label var eu_integr_ess "EU integration ESS"

rename rlgdgr relig_ess
label var relig_ess "Religiosity ESS"

rename vteurmmb ref_eu_ess
label var ref_eu_ess "EU referendum ESS"

rename clsprty partyid_ess
label var partyid_ess "Party ID ESS"

rename prtclcbe partyid_be_ess
label var partyid_be_ess "Party ID ESS Belgium"

rename prtclede partyid_de_ess
label var partyid_de_ess "Party ID ESS Germany"

rename prtclees partyid_es_ess
label var partyid_es_ess "Party ID ESS Spain"

rename prtcldie partyid_ie_ess
label var partyid_ie_ess "Party ID ESS Ireland"

rename prtclept partyid_pt_ess
label var partyid_pt_ess "Party ID ESS Portugal"

rename polintr polint_ess
label var polint_ess "Political interest ESS"

rename hinctnta income_ess 
label var income_ess "Income ESS"

rename mbtru union_ess
label var union_ess "Union membership ESS" 

rename domicil location_ess
label var location_ess "Rural/Urban location ESS"

sort surveyname country id

save "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS8 2016\ESS2016_short", replace

**Update: ESS 2018 DATA

use "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS 2018\ESS2018.dta"

rename cntry country
keep if country == "BE" |  country == "DE" |  country == "ES" |  country == "IE" |  country == "PT"

gen country1 = "Belgium" if country == "BE"
replace country1 = "Spain" if country == "ES"
replace country1 = "Ireland" if country == "IE"
replace country1 = "Portugal" if country == "PT"
replace country1 = "Germany" if country == "DE"

drop country
rename country1 country
label var country "Country"
order country

keep eisced agea gndr clsprty prtcldbe prtclede prtcleie prtclfes prtclept stfgov ///
pspwght dweight name idno country trstep mbtru domicil ///
vote prtvtdbe prtvede2 prtvtees prtvtcie prtvtcp polintr ///
lrscale stfeco stfgov stfdem euftf rlgdgr ctzshipd brncntr vteurmmb mbtru hinctnta ///


generate surveyname = "ESS2018"
label var surveyname "Surveyname"

keep if ctzshipd == "6666"
keep if age >= 18
drop ctzshipd brncntr

gen female_ess = 0
replace female_ess = 1 if gndr == 2
label var female_ess "Female ESS"

gen agegroup1_ess = 0
replace agegroup1_ess =1 if agea <= 34
label var agegroup1_ess "18-34 ESS"

gen agegroup2_ess = 0
replace agegroup2_ess =1 if agea >34 & agea <55
label var agegroup2_ess "35-54 ESS"

gen agegroup3_ess = 0
replace agegroup3_ess =1 if agea >=55
label var agegroup3_ess "55+ ESS"

gen edugroup1_ess = 0
replace edugroup1_ess =1 if eisced == 1 | eisced == 2
label var edugroup1_ess "Less than secondary ESS"

gen edugroup2_ess = 0
replace edugroup2_ess =1 if eisced == 3 | eisced == 4
label var edugroup2_ess "Secondary ESS"

gen edugroup3_ess = 0
replace edugroup3_ess =1 if eisced == 5 | eisced == 6 | eisced == 7
label var edugroup3_ess "More than secondary ESS"

rename dweight dweight_ess
label var dweight_ess "Design weight ESS"

rename pspwght pspweight_ess
label var pspweight_ess "Post stratification & design weight ESS"

rename idno id
label var id "Respondent ID"
tostring id, replace

rename agea age_ess
label var age_ess "Age ESS"

rename gndr gender_ess
label var gender_ess "Gender ESS"

rename eisced edu_ess
label var edu_ess "Education ESS"

rename trstep trust_ep_ess
label var trust_ep_ess "Trust European parliament ESS"

rename vote voted_nat_ess
label var voted_nat_ess "Voted last election National ESS"

rename prtvtdbe voterecall_be_ess
label var voterecall_be_ess "Vote recall National ESS Belgium"

rename prtvede2 voterecall_de_ess
label var voterecall_de_ess "Vote recall National ESS Germany"

rename prtvtees voterecall_es_ess
label var voterecall_es_ess "Vote recall National ESS Spain"

rename prtvtcie voterecall_ie_ess
label var voterecall_ie_ess "Vote recall National ESS Ireland"

rename prtvtcp voterecall_pt_ess
label var voterecall_pt_ess "Vote recall National ESS Portugal"

rename lrscale leftright_ess
label var leftright_ess "Left-right placement ESS"

rename stfeco sat_eco_ess
label var sat_eco_ess "Satisfaction economy ESS"

rename stfgov sat_gov_ess
label var sat_gov_ess "Satisfaction government ESS"

rename stfdem swd_ess
label var swd_ess "SWD ESS"

rename euftf eu_integr_ess
label var eu_integr_ess "EU integration ESS"

rename rlgdgr relig_ess
label var relig_ess "Religiosity ESS"

rename vteurmmb ref_eu_ess
label var ref_eu_ess "EU referendum ESS"

rename clsprty partyid_ess
label var partyid_ess "Party ID ESS"

rename prtcldbe partyid_be_ess
label var partyid_be_ess "Party ID ESS Belgium"

rename prtclede partyid_de_ess
label var partyid_de_ess "Party ID ESS Germany"

rename prtclfes partyid_es_ess
label var partyid_es_ess "Party ID ESS Spain"

rename prtcleie partyid_ie_ess
label var partyid_ie_ess "Party ID ESS Ireland"

rename prtclept partyid_pt_ess
label var partyid_pt_ess "Party ID ESS Portugal"

rename polintr polint_ess
label var polint_ess "Political interest ESS"

rename hinctnta income_ess 
label var income_ess "Income ESS"

rename mbtru union_ess
label var union_ess "Union membership ESS" 

rename domicil location_ess
label var location_ess "Rural/Urban location ESS"

sort surveyname country id

save "C:\Users\Administrator\Desktop\MAPLE\DATA\ESS\ESS 2018\ESS2018_short.dta", replace

**MAPLE DATA

use "C:\Users\Administrator\Desktop\MAPLE\DATA\MAPLE\wave1_merged_weights_cleaned.dta"

use "C:\Users\Administrator\Desktop\MAPLE\DATA\MAPLE\wave1_short"

rename Q18_4 Q19_4
rename Q23_5 Q24_5
rename Q23_6 Q24_6
rename Q25_4 Q26_4

rename Country country
generate surveyname = "MAPLE"
label var surveyname "Surveyname" 
order surveyname

rename ResponseId id
label var id "Respondent ID"

keep WEIGHT_RIM Weight_Cell gender Education age Q17_1 Q40 Q41 Q66 Q36 Q68 Q67 Q66 Q42 Q39 Q38 Q35 Q28 Q27 Q21 Q23 Q15 Q16 Q12 Q13 Q5 Q9 Q8 Q7 Q24_1 Q24_2 ///
id country surveyname

gen female = 1 if gender == "female"
replace female = 0 if gender == "male"
label var female "Female MAPLE"

gen agegroup1 = 0
replace agegroup1 = 1 if age == "18-34"
label var agegroup1 "18-34 MAPLE"

gen agegroup2 = 0
replace agegroup2 = 1 if age == "35-54"
label var agegroup2 "35-54 MAPLE"

gen agegroup3 = 0
replace agegroup3 = 1 if age == "55+"
label var agegroup3 "55+ MAPLE"

gen edugroup1 = 0
replace edugroup1 = 1 if Education == "Low"
label var edugroup1 "Less than secondary MAPLE"

gen edugroup2 = 0
replace edugroup2 = 1 if Education == "Mid"
label var edugroup2 "Secondary MAPLE"

gen edugroup3 = 0
replace edugroup3 = 1 if Education == "High"
label var edugroup3 "More than secondary MAPLE"

rename age age_MA
label var age_MA "Age MAPLE"

rename gender gender_MA
label var gender_MA "Gender MAPLE"

rename Education edu_MA
label var edu_MA "Education MAPLE"

rename WEIGHT_RIM weight_rim_MA
label var weight_rim_MA "Weight RIM MAPLE"

rename Weight_Cell weight_cell_MA
label var weight_cell_MA "Weight Cell MAPLE"

rename Q67 relig_MA
label var relig_MA "Religiosity MAPLE"

rename Q66 income_MA
label var income_MA "Household income MAPLE"

rename Q42 votechoice_eu_MA
label var votechoice_eu_MA "Vote Choice EU MAPLE"

rename Q39 leftright_MA
label var leftright_MA "Left-right placement MAPLE"

rename Q38 votechoice_nat_MA
label var votechoice_nat_MA "Vote Choice National MAPLE"

rename Q35 partyid_MA
label var partyid_MA "Party identification MAPLE"

rename Q36 partyclose_MA
label var partyclose_MA "Party closeness MAPLE"

rename Q28 voterecall_nat_MA
label var voterecall_nat_MA "Vote recall National MAPLE"

rename Q27 voted_nat_MA
label var voted_nat_MA "Voted last national election MAPLE"

rename Q24_1 eu_exit_MA
label var eu_exit_MA "Country should leave EU MAPLE"

rename Q24_2 euro_exit_MA
label var euro_exit_MA "Country should leave Euro MAPLE"

rename Q23 eu_integr_MA
label var eu_integr_MA "EU integration MAPLE"

rename Q21 country_influence_eu_MA
label var country_influence_eu_MA "Country influence on EU MAPLE"

rename Q16 swd_eu_MA
label var swd_eu_MA "SWD EU MAPLE"

rename Q15 swd_MA
label var swd_MA "SWD MAPLE"

rename Q12 eu_benefit_MA
label var eu_benefit_MA "EU membership benefit MAPLE"

rename Q13 euro_benefit_MA
label var euro_benefit_MA "Euro currency benefit MAPLE"

rename Q9 sat_policies_eu_MA
label var sat_policies_eu_MA "Satisfaction EU policies MAPLE"

rename Q7 economy_nat_MA
label var economy_nat_MA "National economic situation MAPLE"

rename Q8 economy_pers_MA
label var economy_pers_MA "Personal economic situation MAPLE"

rename Q68 location_MA
label var location_MA "Rural/Urban location MAPLE"

rename Q40 polknow1_MA
label var polknow1_MA "Political knowledge MAPLE 1"
rename Q41 polknow2_MA
label var polknow2_MA "Political knowledge MAPLE 2"

rename Q17_1 trust_gov_MA
label var trust_gov_MA "Trust government MAPLE"

save "C:\Users\Administrator\Desktop\MAPLE\DATA\MAPLE\wave1_short", replace

**MAPLE DATA Wave 2

use "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave1_2_merged.dta"

drop if Wave == 1

rename Country country
generate surveyname = "MAPLE"
label var surveyname "Surveyname" 
order surveyname

rename ResponseId_w2 id
label var id "Respondent ID"

gen female_MA = 1 if Q3_w2 == 1
replace female_MA = 0 if Q3_w2 == 2
label var female_MA "Female MAPLE"

gen agegroup1 = 0
replace agegroup1 = 1 if Q4A_w2 == 1
label var agegroup1 "18-34 MAPLE"

gen agegroup2 = 0
replace agegroup2 = 1 if Q4A_w2 == 2
label var agegroup2 "35-54 MAPLE"

gen agegroup3 = 0
replace agegroup3 = 1 if Q4A_w2 == 3
label var agegroup3 "55+ MAPLE"

gen edugroup1 = 0
replace edugroup1 = 1 if Q5A_w2 == 1
label var edugroup1 "Less than secondary MAPLE"

gen edugroup2 = 0
replace edugroup2 = 1 if Q5A_w2 == 2
label var edugroup2 "Secondary MAPLE"

gen edugroup3 = 0
replace edugroup3 = 1 if Q5A_w2 == 3
label var edugroup3 "More than secondary MAPLE"

rename Q4_w2 age_MA
label var age_MA "Age MAPLE"

rename Q3_w2 gender_MA
label var gender_MA "Gender MAPLE"

rename Q5_w2 edu_MA
label var edu_MA "Education MAPLE"

rename WEIGHT_RIM_w2 weight_rim_MA
label var weight_rim_MA "Weight RIM MAPLE"

rename WEIGHT_Cell_w2 weight_cell_MA
label var weight_cell_MA "Weight Cell MAPLE"

rename Q67_w2 relig_MA
label var relig_MA "Religiosity MAPLE"
replace relig_MA = Q67_w1 if Wave == 3

rename Q66_w2 income_MA
label var income_MA "Household income MAPLE"
replace income_MA = Q66_w1 if Wave == 3

rename Q119_w2 votechoice_eu_MA
label var votechoice_eu_MA "Vote Recall EU MAPLE"

rename Q118_w2 voted_eu_MA
label var voted_eu_MA "Voted last EU election MAPLE"

rename Q39_w2 leftright_MA
label var leftright "Left-right placement MAPLE"

rename Q38_w2 votechoice_nat_MA
label var votechoice_nat_MA "Vote Choice National MAPLE"

rename Q35_w2 partyid_MA
label var partyid_MA "Party identification MAPLE"

rename Q36_w2 partyclose_MA
label var partyclose_MA "Party closeness MAPLE"

rename Q28_w2 voterecall_nat_MA
label var voterecall_nat_MA "Vote recall National MAPLE"

rename Q27_w2 voted_nat_MA
label var voted_nat_MA "Voted last national election MAPLE"

rename Q24_1_w2 eu_exit_MA
label var eu_exit_MA "Country should leave EU MAPLE"

rename Q24_2_w2 euro_exit_MA
label var euro_exit_MA "Country should leave Euro MAPLE"

rename Q23_w2 eu_integr_MA
label var eu_integr_MA "EU integration MAPLE"

rename Q21_w2 country_influence_eu_MA
label var country_influence_eu_MA "Country influence on EU MAPLE"

rename Q16_w2 swd_eu_MA
label var swd_eu_MA "SWD EU MAPLE"

rename Q15_w2 swd_MA
label var swd_MA "SWD MAPLE"

rename Q12_w2 eu_benefit_MA
label var eu_benefit_MA "EU membership benefit MAPLE"

rename Q13_w2 euro_benefit_MA
label var euro_benefit_MA "Euro currency benefit MAPLE"

rename Q9_w2 sat_policies_eu_MA
label var sat_policies_eu_MA "Satisfaction EU policies MAPLE"

rename Q7_w2 economy_nat_MA
label var economy_nat_MA "National economic situation MAPLE"

rename Q8_w2 economy_pers_MA
label var economy_pers_MA "Personal economic situation MAPLE"

rename Q68_w2 location_MA
label var location_MA "Rural/Urban location MAPLE"

rename Q40_w2 polknow1_MA
label var polknow1_MA "Political knowledge MAPLE 1"
rename Q41_w2 polknow2_MA
label var polknow2_MA "Political knowledge MAPLE 2"

rename Q17_1_w2 trust_gov_MA
label var trust_gov_MA "Trust government MAPLE"

keep weight_cell_MA weight_rim_MA female agegroup1 agegroup2 agegroup3 edugroup1 edugroup2 edugroup3 location_MA relig_MA income_MA ///
votechoice_eu_MA voted_eu_MA polknow2_MA polknow1_MA leftright_MA votechoice_nat_MA partyclose_MA partyid_MA voterecall_nat_MA ///
voted_nat_MA euro_exit_MA eu_exit_MA eu_integr_MA country_influence_eu_MA trust_gov_MA swd_eu_MA swd_MA euro_benefit_MA eu_benefit_MA ///
sat_policies_eu_MA economy_pers_MA economy_nat_MA edu_MA age_MA gender_MA id surveyname country

save "C:\Users\Administrator\Desktop\MAPLE\DATA\Analysis\survey compare\wave2_short", replace
